home *** CD-ROM | disk | FTP | other *** search
/ Amiga Plus 1995 #5 & #6 / Amiga Plus CD - 1995 - No. 5 and 6.iso / pd / spiele / gnuchess / src / test / chesstest / score.c < prev    next >
C/C++ Source or Header  |  1995-07-02  |  1KB  |  54 lines

  1. #include <stdio.h>
  2. char s[100];
  3. FILE *I;
  4. char *p, *q, *r;
  5. int first = 1;
  6. int sco = 0;
  7. int cnt = 0;
  8. int ovs =0;
  9. int ovc = 0;
  10. char last[24];
  11. main (argc, argv)
  12.      int argc;
  13.      char *argv[];
  14. {
  15.   I = fopen (argv[1], "r");
  16.       printf ("  test         right   wrong  total    percent\n");
  17.   while (fgets (s, 100, I) != NULL)
  18.     {
  19. /* p -> name */
  20.       p = s+8;
  21.       for (; *p != '.'; p++);
  22. /* q -> right */
  23.       for (q = p; *q != ' ';q++);
  24.       q++;
  25. /* r -> cnt */
  26.       for (r = q; *r != ' '; r++);
  27.     r++;
  28.       for (; *r != ' '; r++);
  29.       r++;
  30.       *p = '\0';
  31.       if (first)
  32.     {
  33.       strcpy (last, s+8);
  34.       first = 0;
  35.     }
  36.       if (strcmp (s+8, last) == 0)
  37.     {
  38.       sco += atoi (q);
  39.       cnt += atoi (r);
  40.     }
  41.       else
  42.     {
  43.       printf ("%9s\t%d\t%d\t%d\t%d\n", last, sco,cnt - sco, cnt, (int)(((float)sco/(float)cnt)*100.+.5));
  44.       strcpy (last, s+8);
  45.       ovs += sco; ovc += cnt;
  46.       cnt = atoi (r);
  47.       sco = atoi (q);
  48.     }
  49.     }
  50.       printf ("%9s\t%d\t%d\t%d\t%d\n", last, sco,cnt - sco, cnt, (int)(((float)sco/(float)cnt)*100.+.5));
  51.       ovs += sco; ovc += cnt;
  52.       printf ("\ntotal    \t%d\t%d\t%d\t%d\n", ovs, ovc - ovs,ovc,(int)(((float)ovs/(float)ovc)*100.+.5));
  53. }
  54.